#include<iostream>
#include<iomanip>
using namespace std;
const int N = 25;
int dis[N];
int flag[N];
int n, r;

void dfs(int step, int last)
{
	if (step == r) {
		for (int i = 0; i < r; i++) {
			cout << setw(3) << dis[i];
		}
		cout << endl;
		return;
	}
	for (int i = last; i < n; i++) {
		if (!flag[i]) {
			flag[i] = 1;
			dis[step] = i;
			dfs(step + 1, i + 1);
			dis[step] = 0;
			flag[i] = 0;
		}
	}
}
int main()
{
	cin >> n >> r;
	dfs(0, 1);
	return 0;
}